package com.csx.base.design.structure.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cuisongxu
 * @date 2022/9/16 12:13
 */
public class Folder extends Node{

    private List<Node> childrenNodes = new ArrayList<>();

    /**
     * 构造方法需要传入节点名
     *
     * @param name 节点名
     */
    public Folder(String name) {
        super(name);
    }


    @Override
    protected void add(Node child) {
        childrenNodes.add(child);
    }

    @Override
    protected void tree(int space) {
        super.tree(space);
        space++;
        for (Node childrenNode : childrenNodes) {
            childrenNode.tree(space);
        }
    }
}
